package com.lc.pianostudent.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.lc.pianostudent.BaseApplication;
import com.lc.pianostudent.R;
import com.lc.pianostudent.conn.PostRelease;
import com.lc.pianostudent.fragment.FindFragment;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.util.UtilToast;

/**
 * Created by Administrator on 2018/7/3.
 */

public class CircleTextActivity extends BaseActivity{

    @BoundView(R.id.tv_title_name) private TextView tv_title_name;
    @BoundView(R.id.dongtai) private TextView dongtai;

    //发布接口
    public PostRelease postRelease = new PostRelease(new AsyCallBack<PostRelease.PostReleaseInfo>(){

        @Override
        public void onSuccess(String toast, int type, Object o, PostRelease.PostReleaseInfo postReleaseInfo) throws Exception {
            UtilToast.show(toast);
            try {
                ((FindFragment.CallBack)getAppCallBack(FindFragment.class)).onRefresh();
            } catch (Exception e) {
                e.printStackTrace();
            }
            finish();
        }

        @Override
        public void onFail(String toast, int type) throws Exception {
            UtilToast.show(toast);
        }
    });
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_circle_text);

        setBackTrue();


        initView();
    }

    private void initView(){
        tv_title_name.setVisibility(View.INVISIBLE);

        setRightName("发布", R.color.textBlack_2e2e2e, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(TextUtils.isEmpty(dongtai.getText().toString().trim())){
                    UtilToast.show("文字不能为空");
                }else {
                    postRelease.content = dongtai.getText().toString().trim();
                    postRelease.state = "0";
                    postRelease.type = "0";
                    postRelease.user_id = BaseApplication.BasePreferences.readUID();
                    postRelease.execute();
                }

            }
        });
    }
}
